<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function queryData(url) {
      const p = new Promise(function(resolve, reject) {
        const xhr = new XMLHttpRequest()
        xhr.open('get', url)
        xhr.send()

        xhr.onreadystatechange = function() {
          if( xhr.readyState !== 4 ) { return }
          if( xhr.readyState === 4 && xhr.status === 200 ) {
            resolve(xhr.responseText)
          } else {
            reject('服务器有问题')
          }
        }
      })
      return p
    }

    // 串联
    queryData('http://127.0.0.1:3000/data')
      .then(function(res) {
        console.log('success111', res)
        return queryData('http://127.0.0.1:3000/data1')
      })
      .then(function(res) {
        console.log('success2222', res)
        return queryData('http://127.0.0.1:3000/data2')
      })
      .then(function(res) {
        console.log('success3333', res)
      })

    
  </script>
</body>
</html>